package com.xr.miniprogram.controller.user;


import com.xr.common.core.controller.BaseController;
import com.xr.common.core.domain.AjaxResult;
import com.xr.miniprogram.service.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author da
 * @since 2023-09-28
 */
@Api("小程序服务工人控制")
@RestController
@RequestMapping("/miniprogram/staff")
public class MiniProgramStaffController extends BaseController {

    @Resource
    IMiniProgramStaffService staffService;

    /**
     * 根据userId获取工人被分配的订单子项
     * @param userId 用户id
     * @param date 日期
     * @return
     */
    @ApiOperation("根据userId获取工人被分配的订单子项")
    @RequestMapping("/getStaffOrderList/{userId}")
    public AjaxResult getStaffOrderList(@PathVariable("userId") Long userId,String date){
        return success(staffService.getStaffOrderList(userId, date,null));
    }

    /**
     * 根据serviceLogId获取工人被分配的订单服务
     * @param serviceLogId
     * @return
     */
    @ApiOperation("根据serviceLogId获取工人被分配的订单服务")
    @RequestMapping("/getStaffOrderByServiceLogId/{serviceLogId}")
    public AjaxResult getStaffOrderByServiceLogId(@PathVariable("serviceLogId") Long serviceLogId){
        return success(staffService.getStaffOrderByServiceLogId(serviceLogId));
    }

    /**
     * 获取用户每天服务次数
     * @param userId
     * @param
     * @return
     */
    @ApiOperation("获取用户每天服务次数")
    @RequestMapping("/getCount/{userId}")
    public AjaxResult getCountByDate(@PathVariable("userId") Long userId){
        return success(staffService.getCountByDate(userId));
    }
}
